fix(ext/napi): export uv_ref and uv_unref symbols#32562
Draft
bartlomieju wants to merge 2 commits intodenoland:mainfrom
Draft
fix(ext/napi): export uv_ref and uv_unref symbols#32562bartlomieju wants to merge 2 commits intodenoland:mainfrom
bartlomieju wants to merge 2 commits intodenoland:mainfrom
Conversation
Native addons that call `uv_ref`/`uv_unref` (e.g. zeromq) crash with a null pointer dereference because Deno didn't export these symbols. The addon resolves them via `dlsym` at runtime, gets NULL, and segfaults when calling. Add no-op stubs for `uv_ref` and `uv_unref` and export them in the symbol lists. These are no-ops because Deno's NAPI uv polyfill doesn't track handle ref counts. Note: zeromq also needs additional uv functions (uv_poll_*, uv_timer_*, uv_idle_*, etc.) to fully work. There is a more complete uv compat layer in libs/core/uv_compat.rs that could potentially be integrated. Ref denoland#18345 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
uv_refanduv_unrefstubs toext/napi/uv.rsNative addons (e.g. zeromq) that call
uv_ref/uv_unrefcrash with a nullpointer dereference because these symbols are resolved via
dlsymat runtimeand Deno didn't export them.
Reproduction
Crashes with
EXC_BAD_ACCESS (code=1, address=0x0)— the call chain is:Status
This fixes the immediate
uv_unrefcrash, but zeromq also needs additional uvfunctions to fully work:
uv_poll_init_socket,uv_poll_start,uv_poll_stop,uv_timer_init,uv_timer_start,uv_timer_stop,uv_idle_init,uv_idle_start,uv_check_init,uv_check_start,uv_os_getpid,uv_queue_work.There is a more complete uv compat layer in
libs/core/uv_compat.rs(withtimers, idle/check/prepare handles, etc.) gated behind the
uv_compat_exportfeature flag. Integrating that with the NAPI layer's existing uv polyfill in
ext/napi/uv.rswould be the path to full zeromq support.Ref #18345
Test plan
cargo check -p deno_napipassesuv_unrefcrash (now fails later onmissing
uv_poll_init_socket)🤖 Generated with Claude Code